﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using BUS;
using DevExpress.XtraEditors;
namespace QLDT
{
    public partial class frm_PhanQuyen : Form
    {
        public frm_PhanQuyen()
        {
            InitializeComponent();
        }
        private void load()
        {
            int id_nhom = 0;
            if (radioNguoidung.SelectedIndex == 0)
                id_nhom = 1;
            else if (radioNguoidung.SelectedIndex == 1)
                id_nhom = 2;
            else
                id_nhom = 3;
            gridQLPhanQuyen.DataSource = BUS.BUS_HeThong.SelectChucNang_TheoNhom(id_nhom);

        }
        private void frm_PhanQuyen_Load(object sender, EventArgs e)
        {
            load();
        }

        private void radioNguoidung_SelectedIndexChanged(object sender, EventArgs e)
        {
            load();
        }

        private void GridQuyen_Check_DuocPhep_CheckedChanged(object sender, EventArgs e)
        {
            string id_nhom = (radioNguoidung.SelectedIndex + 1).ToString();
            string id_chucnang;
            id_chucnang = gv_QLPhanQuyen.GetRowCellValue(gv_QLPhanQuyen.FocusedRowHandle, "ID_ChucNang").ToString();
            //XtraMessageBox.Show("ID_Nhom= " + id_nhom + "Id_chucnang=" + id_chucnang, "Thông báo");
            if (!BUS_HeThong.updateQuyen(id_nhom, id_chucnang))
            {
                XtraMessageBox.Show("Lỗi", "Thông báo");
                return;
            }
        }
    }
}
